package com.seed.core.builder.datapermis;

import com.seed.core.builder.search.SearchedBuilder;
import com.seed.core.pojo.seed.Seed;
import com.seed.core.query.pojo.Searched;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class DataPermisBuilder {

    private final Seed seed; // 当前访问的模块
    private final List<List<String>> values; // 数据权限配置，形如：column1_eq=value1,cross.column2_eq=value2

    public DataPermisBuilder(Seed seed, List<List<String>> values) {
        this.seed = seed;
        this.values = values;
    }

    public List<Map<String, Searched>> build() {
        List<Map<String, Searched>> ret = new ArrayList<>();
        if(values == null) return ret;

        for (List<String> list: values) {
            ret.add(new SearchedBuilder(seed, list).build());
        }

        return ret;
    }
}
